Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supported STDimension, STDisjoint, STIntersects, STIsClosed, STIsEmpTy, STIsValid PostGIS functions for Geospatial datatypes #3456

Conversation

Mohitraj-g
Copy link

Description

Implemented several GeoSpatial SQL functions that were previously unsupported in Babelfish. The following functions have been added:

  1. STDimension
  2. STDisjoint
  3. STIntersects
  4. STIsClosed
  5. STIsEmpty
  6. STIsValid

Changes include:

  1. Function Implementations:

    • Utilized PostGIS functions where appropriate, with necessary adjustments to ensure compatibility.
  2. Parser Updates:

    • Added function definitions to the SQL parser to recognize these new functions.
    • Ensured proper syntax handling for each function, including parameter types and return values.
  3. Test Cases:

    • Created comprehensive test cases for each function, covering various scenarios including
  4. Error Handling:

    • Implemented appropriate error handling

Testing:

  • All new functions pass the added test cases.
  • Existing functionality remains unaffected.

###Exapmles:

  1. For STIntersects
DECLARE @point1 geometry, @point2 geometry;
SET @point1 = geometry::STPointFromText('POINT(-122.354657658684900 47.658678768678100)', 4326);
SET @point2 = geometry::STPointFromText('POINT(-122.354657658684900 47.658678768678100)', 4326);
SELECT @point1.STIntersects(@point2) AS Intersecting;
go

Output:
Intersecting
------
1
  1. For STDisjoint
DECLARE @point1 geography, @point2 geography;
SET @point1 = geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326);
SET @point2 = geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326);
SELECT @point1.STDisjoint(@point2) AS disjoint;
go

Output:
disjoint
------
0

  1. For STDimension
DECLARE @point geometry;
SET @point = geometry::STPointFromText('POINT(-122.34900 47.65100)', 4326);
SELECT STDimension(@point);
go

Output:

------
0

  1. For STIsEmpty
DECLARE @point geometry;
SET @point = geometry::STPointFromText('POINT(-122.34900 47.65100)', 4326);
SELECT STIsEmpty(@point);
go

Output:

------
0
  1. For STIsValid
DECLARE @point geography;
SET @point = geography::STPointFromText('POINT(-122.34900 47.65100)', 4326);
SELECT STIsValid(@point);
go

Output:

------
1
  1. For STIsClosed
DECLARE @point geography;
SET @point = geography::STPointFromText('POINT(-122.34900 47.65100)', 4326);
SELECT STIsClosed(@point);
go

Output:

------
0

Issues Resolved

Task: BABEL-5579

Test Scenarios Covered

  • Use case based - Yes

  • Boundary conditions - Yes

  • Arbitrary inputs - Yes

  • Negative test cases - Yes

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…y, STIsValid PostGIS functions for Geospatial datatypes
@Mohitraj-g Mohitraj-g closed this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant